const user = localStorage.getItem("bigScreenUser")
const state = {
  curCategoryId: parseInt(sessionStorage.getItem("curCategoryId")) || 1,
  user: user==='undefined' ? null : JSON.parse(user),
  token: sessionStorage.getItem("bigScreenToken"),  
	echartsAutoTime:6000, //6秒
	isScale:true,
}

const mutations = {
  setCurCategoryId: (state, curCategoryId) => {
      state.curCategoryId = curCategoryId
      sessionStorage.setItem("curCategoryId", curCategoryId)
  },

  setUser: (state, user) => {
      state.user = user
      localStorage.setItem("bigScreenUser", JSON.stringify(user))
  },
  
  setToken: (state, token) => {
      state.token = token
      sessionStorage.setItem("bigScreenToken", token)
  },
}

const actions = {
  setCurCategoryId({commit}, curCategoryId) {
      commit('setCurCategoryId', curCategoryId)
  },
  setUser({commit}, user) {
      commit('setUser', user)
  },
  setToken({commit}, token) {
      commit('setToken', token)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
